//
//  TKFrameMaker.m
//  EasyKit
//
//  Created by zx on 2017/12/22.
//  Copyright © 2017年 a186f13. All rights reserved.
//

#import "TKFrameMaker.h"

@interface TKFrameMaker() <TKFrameDelegate>

@property (nonatomic, weak) UIView *view;
@property (nonatomic, strong) NSMutableArray *frames;

@end

@implementation TKFrameMaker

- (id)initWithView:(UIView *)view {
    self = [super init];
    if (!self) return nil;
    
    self.view = view;
    
    return self;
}

- (void)install {
    for (TKFrame *tkFrame in self.frames) {
        
    }
}

#pragma mark - Public Func

- (TKFrame *)left {
    return [self addTKFrameWithFrameAttribute:TKFrameAttributeLeft];
}

- (TKFrame *)top {
    return [self addTKFrameWithFrameAttribute:TKFrameAttributeTop];
}

- (TKFrame *)right {
    return [self addTKFrameWithFrameAttribute:TKFrameAttributeTop];
}

- (TKFrame *)bottom {
    return [self addTKFrameWithFrameAttribute:TKFrameAttributeTop];
}

- (TKFrame *)leading {
    return [self addTKFrameWithFrameAttribute:TKFrameAttributeTop];
}

- (TKFrame *)trailing {
    return [self addTKFrameWithFrameAttribute:TKFrameAttributeTop];
}

- (TKFrame *)width {
    return [self addTKFrameWithFrameAttribute:TKFrameAttributeTop];
}

- (TKFrame *)height {
    return [self addTKFrameWithFrameAttribute:TKFrameAttributeTop];
}

- (TKFrame *)centerX {
    return [self addTKFrameWithFrameAttribute:TKFrameAttributeTop];
}

- (TKFrame *)centerY {
    return [self addTKFrameWithFrameAttribute:TKFrameAttributeTop];
}

#pragma mark - Private Func

- (TKFrame *)addTKFrameWithFrameAttribute:(TKFrameAttribute)frameAttribute {
    TKFrame *tkFrame = [[TKFrame alloc] init];
    tkFrame.delegate = self;
    tkFrame.frameArrribute = frameAttribute;
    [self.frames addObject:tkFrame];
    return tkFrame;
}

#pragma mark - TKFrameDelegate

- (TKFrame *)constraint:(TKFrame *)constraint addFrameAttribute:(TKFrameAttribute)frameAttribute {
    return [self addTKFrameWithFrameAttribute:frameAttribute];
}

#pragma mark - Getter

- (NSMutableArray *)frames {
    if (!_frames) {
        _frames = [[NSMutableArray alloc] init];
    }
    return _frames;
}

@end
